<script lang='ts'  setup>
import TreeMenu from './TreeMenu.vue'
import { PropType } from 'vue'
interface IMenuProps {
    menuName: string
    icon: string
    children: IMenuProps[]
    path: string
    _id: string
    menuType: number
}
defineProps({
    userMenu: Array as PropType<IMenuProps[]>
})

// TODO 研究递归菜单
</script>

<template >
    <template v-for="menu in userMenu">
        <el-sub-menu :index="menu._id" :key="menu._id"
            v-if="menu.children && menu.children.length >= 1 && menu.children[0].menuType == 1">
            <template #title>
                <el-icon v-if="menu.icon">
                    <component :is="menu.icon" />
                </el-icon>
                <span>{{ menu.menuName }}</span>
            </template>
            <tree-menu :user-menu="menu.children"></tree-menu>
        </el-sub-menu>
        <el-menu-item v-else-if="menu.menuType == 1" :index="menu.path" class=" pl-[50px]">
            <template #title>
                <span>{{ menu.menuName }}</span>
            </template>
        </el-menu-item>
    </template>

</template>
